/**
 * 判断主机为是大端还是小端模式
*/
#include <stdio.h>

static union {
    char c[4];
    unsigned int l;
} endian_test = {{'l', '?', '?', 'b'}};

#define ENDIANNESS ((char)endian_test.l)

int main(){
    if('b' == ENDIANNESS){
        printf("it's big endian!\n");
    }
    else{
        printf("it's little endian!\n");
    }

    return 0;
}